<?php
/**
 * Copyright (c) 2009, Microsoft
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of Microsoft nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Microsoft ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Microsoft BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * @category   Microsoft
 * @package    WebErrorPHPToolkit
 * @subpackage Error
 * @version    $Id: Error.php 2009-10-09 08:00:00Z unknown $
 * @copyright  Copyright (c) 2009, Microsoft (http://www.microsoft.com)
 * @author     jeff00seattle
 *
 * Custom 404 PHP page Using Bing API best fit search.
 */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<!--
It's a good idea to add this meta tag to the top of a 404 page just
in case a search engine lands on it or gets the header wrong.
That in place you should have your bases covered in case of an
accident or confused bot.
-->
<meta name="robots" content="noindex, nofollow"/>
<title>
  We are sorry, the page you requested cannot be found.
</title>

<link rel="stylesheet" type="text/css" href="/errordocs/WebErrorPHPToolkit/style/web_error.css" />
<link rel="stylesheet" type="text/css" href="/errordocs/WebErrorPHPToolkit/style/web_error_search_bar.css" />
<link rel="stylesheet" type="text/css" href="/errordocs/WebErrorPHPToolkit/style/web_error_result_list.css" />
<link rel="stylesheet" type="text/css" href="/errordocs/WebErrorPHPToolkit/style/web_error_error_list.css" />
<link rel="stylesheet" type="text/css" href="/errordocs/WebErrorPHPToolkit/style/web_error_image_gallery.css" />

<!-- JavaScript Strings Support -->
<script type="text/javascript" src="/errordocs/WebErrorPHPToolkit/js/error_404.js"></script>
<script type="text/javascript" src="/errordocs/WebErrorPHPToolkit/js/string_support.js"></script>
<script type="text/javascript" src="/errordocs/WebErrorPHPToolkit/js/string_format.js"></script>
<script type="text/javascript" src="/errordocs/WebErrorPHPToolkit/js/string_builder.js"></script>
<script type="text/javascript" src="/errordocs/WebErrorPHPToolkit/js/document_helper.js"></script>
<script type="text/javascript" src="/errordocs/WebErrorPHPToolkit/js/bing_json.js"></script>

</head>
<body class="we_Body">

<!-- Initial Error Box -->
<div id="Content" class="we_Content">
  <div id="errorBar" class="we_ebBar">
    <div id="errorTitle" class="we_ebTitle" >
        Sorry, the page you requested cannot be found.
    </div>
    <div id="errorDetail" class="we_ebDetails" style="display:none; clear:both;" >
      These are the best search results for similar pages on this site.
      <br />
      You can type your own query to search further.
    </div>
  </div>

<?php

/*
 * Including main PHP body which is very simple script just gets the request URI
 * from the server variables, this will be the address of the page (relative to
 * the root of your site) that was requested, since this request has caused a
 * 404 error this could either be a page you have moved or a page that never existed.
 */


require_once 'library/ErrorUpload.php';
web_error_upload();

?>
  <!-- Search Bar -->
  <div id="searchBar" class="we_sbBar" style="display:none; clear:both;" >
    <div id="searchForm" class="we_sbForm" >
      <div class="we_sbControls">
        <div class="we_sbBD">
          <div class="we_sbB">
            <input  id="SearchTerms"
                        class="we_sbQBox"
                        type="text"
                        name="searchText"
                        onkeydown="searchOnKeyDown(event);"
                        value=""
                        style="background-image: url(<?php  echo site_variable_get('BingSearchAssetLogoBigDark', ''); ?>);"
                        />
            <input  id="DoSearch"
                        class="we_sbQBtn"
                        type="image"
                        src="<?php echo site_variable_get('BingSearchAssetIcon24', ''); ?>"
                        onclick="searchBingRequest('onClick'); return false;"
                        value="Submit now"
                        alt="Submit now"
                        name="submit_search_box"
                        />
          </div>
        </div>
      </div>
      <div id="buttonWebBing" class="we_sbWebBingButton">
        <a href="<?php echo site_variable_get('BingSearchAssetUrlEndpoint', ''); ?>">
         <img class="we_sbWeb" src="/errordocs/WebErrorPHPToolkit/images/Web.png" alt="Bing" style="border-width:0" />
        </a>
      </div>
    </div>
  </div>

  <div id="resultsSection" class="we_srResultsSection" style="display:none; clear:both;">
        <div id="resultsHeader" class="we_srHeader" style="display:none; clear:both;">Results are included from <span id="resultSite" class="we_srResultsSites"></span>, search terms: <span id="resultQuery" class="we_srResultsTerms"></span>
          <span id="resultNoQuery" class="we_srNoResultsTerms"></span>
          <span id="resultRecourseQuerySection" style="visibility:hidden">Show just the results for <a id="resultRecourseQuery" href="#">test</a>.</span>
        </div>
        <div id="navigation" class="we_srNavigation"></div>
        <div id="resultListWeb" class="we_srResultList"></div>
        <div id="resultImageGallery" class="we_imgGallery"></div>
  </div>

  <div id="errorSection" class="we_esErrorSection" style="display:none; clear:both;">
    <div id="errorList" class="we_esErrorList"></div>
  </div>

  <div id="messageSection" class="we_msgSection" style="display:none; clear:both;">
    <div id="messageList" class="we_msgList"></div>
  </div>

  <!-- Upload Client -->
  <script language="JavaScript">setupSearchOnLoad();</script>
  
  <!-- Footer -->
  <div class="footer" style="display:none; clear:both;">
	<?php 
		foreach ( session_get_messages("error") as $error ) {
		  print '<p><span style="color: #FF0000;"><pre>';
          print_r($error[0]);
          print '</pre></span></p>';
        }
    ?>
  </div>
</div> <!-- end of Contents -->
</body>
</html>